package com.yc.navy.goods.controller;

import java.util.HashMap;
import java.util.Map;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.yc.navy.goods.config.Spark;
//import com.spark.Spark;


/**
 * 讯飞大模型
 * @author 寻
 *
 */
@RestController
@RequestMapping("/spark")
public class SparkController {
	
	@RequestMapping("/spark")
	public Map<String ,Object> spark(@RequestParam("problem") String problem){
		System.out.println(problem);
		Spark sp = new Spark();
		sp.startSpark(problem);
		String ss = sp.answer;
		
		while (ss == null) {
			try {
				Thread.sleep(1000);
			} catch (InterruptedException e) {
				e.printStackTrace();
			} // 休眠时间为5000毫秒（5秒）
		}
		
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("answer", ss);
		
		return map;
	}
}
